package com.centaur0.webfilter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.centaur0.security.AutenticatorVerifier;
import com.centaur0.security.Credentials;

public class LoginFilter implements Filter {

	public void init(FilterConfig filterConfig) throws ServletException {}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		String un  = request.getParameter("oirausu");
		String pwd = request.getParameter("shnes");
		if(!AutenticatorVerifier.verify(new Credentials(un, pwd))){
			request.getRequestDispatcher("login.html").forward(request, response);
		}
	}

	public void destroy() {}

}
